<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1 v-cloak v-on:click="handler">{{msg}}</h1>
        <h1 v-cloak @click="handler">{{msg}}</h1>

        <!-- <ul>
            <li v-for="i in 10">{{i}}</li>
        </ul> -->

        <ul>
            <li v-for="(item,index) in list" v-show="item.age<=20" @click="fun1(index)">
                {{item.name}}
            </li>
        </ul>

        <div v-if="flag">{{msg}}</div>
        <div v-show="!flag">{{msg}}</div>
    </div>
    <script src="vue-2.4.0.js"></script>
    <script>
        let vm = new Vue({
            el: "#app", //声明vue的代码作用的范围
            data: {
                flag: true,
                msg: "hello world",
                list: [{
                    name: "小明",
                    age: 18,
                }, {
                    name: "小龙",
                    age: 28,
                }, {
                    name: "小苗",
                    age: 19,
                }, {
                    name: "张森",
                    age: 20,
                }, {
                    name: "小微",
                    age: 18,
                }, {
                    name: "小宁",
                    age: 20,
                }, ],
            },
            methods: {
                handler() {
                    alert(this.msg);
                },
                fun1(index) {
                    alert(index);
                    //参数不加this
                },
            },
        });
        //new Vue中的可以放的这些属性都叫选项对象
    </script>
</body>

</html>